package com.flyoil.petromp.ui.activity.activity_matter;

import android.widget.LinearLayout;
import android.widget.TextView;

import com.flyoil.petromp.R;
import com.flyoil.petromp.base.BaseActivity;
import com.flyoil.petromp.entity.entity_order.MapListEntity;
import com.flyoil.petromp.mvp_p.MessagePresenter.OrderGoodsMessagePresenter;
import com.flyoil.petromp.mvp_v.MessageUIView.OrderGoodsMessageUIView;
import com.flyoil.petromp.utils.OrderUtl.OrderMessageUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 物资明细详情界面
 */
public class OrderGoodsMessageActivity extends BaseActivity implements OrderGoodsMessageUIView {
    private LinearLayout line_basic;
    private OrderMessageUtil orderMessageUtil;
    private String order_type;
    private OrderGoodsMessagePresenter presenter;

    @Override
    protected int getContentViewResId() {
        return R.layout.activity_matter_goods_message;
    }

    @Override
    protected void initViews() {
        super.initViews();

        order_type = getIntent().getStringExtra("order_type");
        if (order_type == null) {
            order_type = "";
        }
        orderMessageUtil = new OrderMessageUtil(mContext);
        setTextTitleName(orderMessageUtil.getOrderGoodsMessageTitle(order_type));
        setBackOnclickListner(mContext);
        line_basic = $(R.id.line_matter_goods_message_basic);
        presenter = new OrderGoodsMessagePresenter(this, order_type);
    }

    @Override
    protected void initdatas() {
        super.initdatas();
        Map<String, Object> map = new HashMap<>();
        map.put("id", getIntent().getIntExtra("id", 0));
        presenter.initNetworkData(map);
    }


    @Override
    public void updataToUI(List data) {
        if (data == null) {
            onDataError(null);
        }
        if (data != null && data.size() == 0) {
            onDataNull(null);
        }
    }

    @Override
    public void upDataTextsView(List data) {
        if (data != null && data.size() > 0) {
            onDataSucceed();
        }
        orderMessageUtil.init_text_map_view(data, line_basic);

    }

    @Override
    public void upDataImgsView(String name, List data) {
        if (data != null && data.size() > 0) {
            onDataSucceed();
        }
        orderMessageUtil.init_imgs_view(name, data, line_basic);
    }

    @Override
    public void upDataRemarkView(MapListEntity entity) {
        if (entity != null) {
            onDataSucceed();
        }
        orderMessageUtil.init_remark_view(entity, line_basic);
    }
}
